# -*-coding = utf-8 -*-

# @Time: 2021/4/4 14:05
# @Author: bistro
# @File: p781.py
# @Software: PyCharm
# 森林里的兔子
from typing import List
from math import ceil
"""
 1. 全部相同
 2. 全部不同
 3. 部分相同
"""


class Solution:
    def numRabbits(self, answers: List[int]) -> int:
        least = 0
        if answers:
            count_dict = {}
            for i in answers:  # 统计个数
                count_dict[i] = count_dict.get(i, 0) + 1
            for k, v in count_dict.items():
                rod = v // (k + 1)  # 轮数
                rem = v % (k + 1)  # 余数
                least += rod * (k + 1)
                if rem != 0:
                    least += k + 1
        return least


"""
测试用例
s = Solution()
print(s.numRabbits([1, 0, 1, 0, 1]))
"""
